'use strict'

module.exports = async (c, next) => {

    let token = c.headers.authorization || c.query.token

    if (!token) {
        return c.status(403).send('TOKEN NULL')
    }

    let r = c.service.tok.verify(token)

    if(!r.ok) {
        return c.status(403).send(r.errcode)
    }

    //把成功验证后的解密的用户数据方到c.box 中
    c.box.user = r.data

    await next()


}